import { http } from '@/utils/http'
import type { LoginRequest, LoginResponse, UserInfo } from '@/types/auth'

export const authApi = {
  // 登录
  login: (data: LoginRequest) => {
    return http.post<LoginResponse>('/api/auth/login', data)
  },

  // 登出
  logout: () => {
    return http.post('/api/auth/logout')
  },

  // 获取用户信息
  getUserInfo: () => {
    return http.get<UserInfo>('/api/auth/user-info')
  },

  // 刷新Token
  refreshToken: (refreshToken: string) => {
    return http.post<LoginResponse>('/api/auth/refresh-token', { refreshToken })
  },

  // 获取用户权限
  getUserPermissions: () => {
    return http.get<string[]>('/api/auth/permissions')
  },

  // 修改密码
  changePassword: (data: any) => {
    return http.post('/api/auth/change-password', data)
  },

  // 重置密码
  resetPassword: (data: any) => {
    return http.post('/api/auth/reset-password', data)
  },

  // 更新用户资料
  updateProfile: (data: any) => {
    return http.put('/api/auth/profile', data)
  }
}